package cn.john.hrm.properties;

import cn.john.hrm.LoginUserConstant;
import cn.john.hrm.util.ValidUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "auth.client")
public class Oauth2ClientDetailsProperties {
    private Oauth2ClientDetails website;
    private Oauth2ClientDetails system;

    public Oauth2ClientDetails getClientDetails(Integer type) {
        ValidUtils.assertNotNull(type, "用户类型不能为空!!!");
        if(type.intValue() == LoginUserConstant.LOGIN_USER_ADMIN.intValue()) {
            return system;
        } else if (type.intValue() == LoginUserConstant.LOGIN_GENERAL.intValue()) {
            return website;
        }
        return null;
    }

    public Oauth2ClientDetails getWebsite() {
        return website;
    }

    public void setWebsite(Oauth2ClientDetails website) {
        this.website = website;
    }

    public Oauth2ClientDetails getSystem() {
        return system;
    }

    public void setSystem(Oauth2ClientDetails system) {
        this.system = system;
    }
}
